<?php

namespace app\apiadmin\model\liveManager;

use think\Model;

class LiveManagerModel extends Model
{

    protected $name = "siyu_live_manager";

    protected $pk = "id";

    public static function pageMap($map, $offset, $limit)
    {
        return self::where($map)->limit($offset, $limit)->order('create_time desc')->cache(false)->select();
    }

    public static function pageMapCount($map)
    {
        return self::where($map)->count();
    }

    /**
     *  添加一条直播数据
     *
     * @param array $param
     * @return bool
     */
    public static function add($param)
    {
        $liveModel = new LiveManagerModel();
        $isOk = $liveModel->save($param);
        if ($isOk) {
            return $liveModel->getLastInsID();
        } else {
            return false;
        }
    }

    /**
     *  假删除一个直播数据
     *
     * @param int $id
     */
    public static function del($id)
    {
        $recoder = self::where(['id' => $id])->find();
        if (!empty($recoder)) {
            $ret = LiveManagerModel::cache(false)->update(["del" => 1], ["id" => $id, "status" => 0]);
            return $ret;
        }
        return false;
    }

}
